package com.example.logisticsingle.Config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 *

 *
 */
@Configuration
public class RestTemplateConfig {
    private final static int TIME_OUT = 50000;

    @Bean
    public RestTemplate restTemplate() {
        HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
        factory.setConnectionRequestTimeout(TIME_OUT);
        factory.setConnectTimeout(TIME_OUT);
        factory.setReadTimeout(TIME_OUT);
        RestTemplate restTemplate = new RestTemplate(factory);
        restTemplate.getMessageConverters().add(new RestMappingJackson2HttpMessageConverter());
        return restTemplate;
    }
}
